from pathlib import Path
from pydantic_settings import BaseSettings, SettingsConfigDict
from typing import Optional


class Settings(BaseSettings):
    model_config = SettingsConfigDict(env_file='.env', env_file_encoding='utf-8')
    upload_harp_dir: Path = Path("./uploads/harp")  # 直接定义为Path类型
    upload_sozluk_dir: Path = Path("./uploads/sozluk")

    def __init__(self, **data):
        super().__init__(**data)
        self.upload_harp_dir.mkdir(parents=True, exist_ok=True)
        self.upload_sozluk_dir.mkdir(parents=True, exist_ok=True)

    base_url: str = "http://127.0.0.1:8000"
    db_host: str
    db_port: str
    db_user: str
    db_pass: str
    db_name: str
    db_uri: Optional[str] = None
